package mya.mes.mdc.logic.utils;

public class PlcIntArray {

    private static char[] revertArray(char[] chArray) {
        if (chArray == null) {
            return chArray;
        }
        if (chArray.length == 0) {
            return chArray;
        }
        char[] tmp = new char[chArray.length];

        for (int i = 0; i < chArray.length; i++) {
            tmp[i] = chArray[chArray.length - i - 1];
        }

        return tmp;
    }


    public static char[] getChArray(Integer value) {

        String binaryStr = Integer.toBinaryString(value);

        char[] chArray = binaryStr.toCharArray();

        //从右往左
        //反转之后，[0]= 个位 ，[1] = 十位...
        char[] revertArray = revertArray(chArray);

        return revertArray;
    }
}
